package taewanme.gae.bookmark.resource;

import javax.annotation.Resource;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import taewanme.gae.bookmark.model.BookMark;
import taewanme.gae.bookmark.model.User;
import taewanme.gae.bookmark.service.BookmarkServiceImpl;
import taewanme.gae.bookmark.service.UserServiceImpl;

@Component
@Path("users")
public class UserResourceImpl {
	
	@Resource
	private UserServiceImpl userService;
	
	
	@GET
	@Path("{email}")
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public User test(@PathParam("email") String email){
		return userService.getUser(email);
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public User registerUser(User user){
		userService.registerUser(user);
		return userService.getUser(user.getMail());
	}
}
